export default defineEventHandler(async (event) => {
  const id = getRouterParam(event, 'id');
  const body = await readBody(event);

  // 模拟更新资源
  const updatedResource = {
    id: parseInt(id),
    name: body.name,
    code: body.code,
    description: body.description || '',
    category_id: body.category_id,
    resource_type: body.resource_type || 'PHYSICAL',
    properties: body.properties ? JSON.stringify(body.properties) : '{}',
    capabilities: body.capabilities ? JSON.stringify(body.capabilities) : '{}',
    constraints: body.constraints ? JSON.stringify(body.constraints) : '{}',
    metadata: body.metadata ? JSON.stringify(body.metadata) : '{}',
    tech_implementation_id: body.tech_implementation_id || null,
    data_schema_id: body.data_schema_id || null,
    ui_config_id: body.ui_config_id || null,
    api_config_id: body.api_config_id || null,
    lifecycle_status: body.lifecycle_status || 'ACTIVE',
    effective_start: body.effective_start || null,
    effective_end: body.effective_end || null,
    status: body.status || 1,
    tenant_id: 1,
    creator: 'admin',
    create_time: new Date().toISOString(),
    updater: 'admin',
    update_time: new Date().toISOString(),
    deleted: 0,
  };

  return {
    code: 0,
    data: updatedResource,
    msg: '资源更新成功',
  };
});
